<template>
  <up-popup :show="show" mode="bottom" :round="10" @close="handleCancel">
		<view class='popup'>
      <div class="popup-header">
        <view class="popup-title">用户审核</view>
      </div>
      <scroll-view class="popup-content" scroll-y>
        <up-form class="p-[30rpx]">
          <up-form-item label="昵称">
            <up-input v-model="formData.nickname" disabled placeholder="请输入昵称"></up-input>
          </up-form-item>
          <up-form-item label="状态">
            <up-radio-group v-model="formData.status">
              <up-radio v-for="item,index in statusList" :key="index" :name="item.value" :label="item.text"></up-radio>
            </up-radio-group>
          </up-form-item>
          <up-form-item v-if="formData.status == 3" label="拒绝原因">
            <up-textarea v-model="formData.rz_fail" label="" placeholder="请输入拒绝原因"></up-textarea>
          </up-form-item>
        </up-form>
      </scroll-view>
      <div class="popup-footer">
        <up-button type="primary" block plain @click="handleCancel">取 消</up-button>
        <up-button class="ml-[30rpx]" type="primary" block @click="handleConfirm">确 定</up-button>
      </div>
		</view>
	</up-popup>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
const emit = defineEmits(['cancel', 'confirm'])

const show = ref(false)
const formData = ref<any>({})
const statusList = ref([
  {
    text: "已审核",
    value: 1
  },
  {
    text: "已拒绝",
    value: 3
  },
])
function close () {
	show.value = false
}
function open (item:any) {
  show.value = true
  formData.value = {
    nickname: item.nickname,
    status: item.status,
    user_id: item.id,
    rz_fail: ''
  }
}

function handleCancel() {
  close()
  emit('cancel')
}

function handleConfirm() {
  close()
  emit('confirm', formData.value)
}


defineExpose({
  open,
  close
})
</script>

<style scoped lang="scss">
.popup {

	.popup-header {
    height: 100rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    // box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);

    .popup-title {
      font-size: 32rpx;
      font-weight: 500;
    }
	}

	.popup-content {
    // height: 40vh;
	}

  .popup-footer {
    display: flex;
    padding: 20rpx 30rpx;
    box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);

  }
}
</style>